import { Controller, Get, Query } from '@nestjs/common';
import { CalculateBetService } from './calculate-bet.service';

@Controller('calculate-bet')
export class CalculateBetController {
  constructor(private readonly calculateBetService: CalculateBetService) {}

  @Get()
  async findAll(@Query() args = {}) {
    const calcBets = await this.calculateBetService.findAll(args);
    return calcBets.map((calcBet) => {
      const { plan, bet } = calcBet;
      const { leftTower, rightTower, btSpan } = bet;
      const { PointTower } = leftTower;
      const { x, y } = PointTower!;
      return {
        towerPoint: { x0: x, y0: y },
        btSpan,
        Hi: plan.H,
        h: rightTower.altitude - leftTower.altitude,
        w: plan.w,
      };
    });
  }
}
